import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * Thread na konzolove ovladanie botika :>
 * 
 * @author harph
 * 
 */
public class ControlThread extends Thread {
	String command;

	public ControlThread() {
		command = "";
	}

	void analyzeCommand() {
		if (command.equalsIgnoreCase("exit")) {
			for (int i = 0; i < Run.bot.getChannels().length; i++)
				Run.bot
						.partChannel(Run.bot.getChannels()[i],
								"sajonara smradi");

			Run.bot.quitServer("ill be back");
			Run.qog.turnOff();
			System.exit(0);
		}
	}

	@Override
	public synchronized void run() {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader stdin = new BufferedReader(isr);

		while (true) {
			try {
				command = stdin.readLine();
				analyzeCommand();
			} catch (IOException e) {
				System.err.println("DEBUG: error - InputThread - readLine");
			}
		}
	}
}
